import httb from '../../../assets/js/HTTPS';
const api_getRoomLIst = 'roomList'
const api_getHotelInventories = 'getHotelInventories'

function createAction(method, api, mtype, init) {
    if (init === 'init') {
        return async function({ dispatch, commit }, params = {}) {
            dispatch('hideRouteLoading', false);
            const res = await httb[method](api, params)
            dispatch('hideRouteLoading', true)
            mtype && res.data && commit(mtype, res.data)
            return res
        }
    }
    return async function({ dispatch, commit }, params = {}) {
        const res = await httb[method](api, params)
        mtype && res.data && commit(mtype, res.data)
        return res
    }
}

export default {
    getRoomLIst: createAction('get', api_getRoomLIst),
    getHotelInventories: createAction('get', api_getHotelInventories),
    getStayInfo: createAction('get', 'getStayInfo'),
    getCloseRooms: createAction('get', 'getCloseRooms'),

}